/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.project;

import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 生成文档
 * @author zpy
 * @version 1.0.0
 */
public enum GenerateDocument {
    /**
     * 密评方案
     */
    SCHEME_DOC("密评方案","系统"),
    /**
     * 密评报告
     */
    REPORT_DOC("密评报告","系统");

    private final String name;
    private final String type;

    GenerateDocument(String name, String type){
        this.name = name;
        this.type = type;
    }

    public String getName(){
        return this.name;
    }
    public String getType(){
        return this.type;
    }

    public static GenerateDocument fromName(String name){
        return Stream.of(GenerateDocument.values())
                .filter(gd-> StringUtils.equals(gd.getName(),name))
                .findFirst().orElse(null);
    }

    public static List<GenerateDocument> findSystemDocuments(){
        return Stream.of(GenerateDocument.values())
                .filter(gd-> StringUtils.equals(gd.getType(),"系统"))
                .collect(Collectors.toList());
    }

}